﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Duality;
using Duality.Components;
using Duality.Components.Renderers;
using Duality.Resources;
using OpenTK;

namespace PhoenixCrab.Interface
{
    [Serializable]
    public class MouseCursor:Component, ICmpUpdatable
    {
        public void OnUpdate()
        {
            IEnumerable<Camera> cam = Scene.Current.Cameras;
            Rect r = cam.ElementAt(0).SceneOrthoAbs;


            Vector2 v = new Vector2(r.W / 2, r.H / 2);
            Vector2 cursor = new Vector2(GameObj.GetComponent<SpriteRenderer>().Rect.W/2, 
                GameObj.GetComponent<SpriteRenderer>().Rect.H/2);
            



            v = DualityApp.Mouse.Pos - v + cursor;


            Vector3 p = GameObj.Transform.Pos;
            p.Xy = v;
            GameObj.Transform.Pos = p;

        }
    }
}
